
# while循环输出九九乘法表 左上角
raw = 9
i = 1
while i <= raw:
    j = 1
    while j <= i:
        print("{}*{}={:<4}".format(j, i, i * j), end="")
        j += 1
    print()
    i += 1

print("=" * 70)

i = 1
while i <= raw:
    j = raw - i + 1
    while j > 0:
        print("{}*{}={:<4}".format(i, j, j*i), end="")
        j -= 1
    i += 1
    print()

print("=" * 70)

# while循环输出九九乘法表  右上角
raw = 9
i = 1
while i <= raw:
    j = raw - i
    # 输出前面的占位
    while j > 0:
        print(" " * 8, end="")
        j -= 1
    k = i
    while k > 0:
        print("{}*{}={:<4}".format(k, i, k * i), end="")
        k -= 1
    print()
    i += 1

print("=" * 70)

i = raw
while i > 0:
    j = i
    k = raw - i
    while k > 0:
        print(" " * 8, end="")
        k -= 1
    while j > 0:
        print("{}*{}={:<4}".format(j, i, j*i), end="")
        j -= 1
    print()
    i -= 1

print("=" * 70)

# for循环输出九九乘法表，左上角
for i in range(1,10):
    for j in range(1,i+1):
        print("{}*{}={:<4}".format(i, j, i*j), end="")
    print()

print("=" * 70)

for i in range(1,10):
    for j in range(i,10):
        print("{}*{}={:<4}".format(i, j, i*j), end="")
    print()

print("=" * 70)

# 右上角
for i in range(1,10):
    k = raw - i
    for j in range(1,k+1):
        print(" " * 8, end="")
    n = i
    for n in range(n, 0, -1):
        print("{}*{}={:<4}".format(n, i, n*i), end="")
    print()

print("=" * 70)

for i in range(9, 0, -1):
    # 输出前面的占位
    for k in range(raw-i,0,-1):
        print(" " * 8, end="")
    for j in range(i, 0, -1):
        print("{}*{}={:<4}".format(j, i, j*i), end="")
    print()

